/*
 * @Description: 编辑弹窗配置
 * @Author: HuiSir<https://gitee.com/huisir001>
 * @Date: 2025-07-31 15:30:58
 * @LastEditTime: 2025-08-23 18:22:42
 */
import { defineFormOptions } from "@/components/TablePage/predefined";

export default defineFormOptions(() => [
  {
    label: "角色名称",
    component: "input",
    key: "name",
    props: {
      placeholder: "请输入角色名称",
    },
    rules: {
      required: true,
    },
  },
  {
    label: "角色编码",
    component: "input",
    key: "code",
    props: {
      placeholder: "输入编码(英文字符)",
    },
    rules: [
      {
        required: true,
      },
      {
        pattern: /^[a-zA-z_-]+$/,
        trigger: "blur",
        message: "编码须为英文及“_”或“-”组成",
      },
    ],
  },
  {
    label: "角色描述",
    component: "input",
    key: "description",
  },
  {
    label: "权限配置",
    key: "permissionIds",
    slot: "permissionIds",
    rules: [
      {
        validator(_rule, value, callback) {
          if (!value || !value.length) {
            return callback(new Error("权限不能为空"));
          }
          callback();
        },
        trigger: "blur",
      },
      {
        required: true,
      },
    ],
  },
]);
